<?php


namespace App\Models\Log;


use App\Models\BaseModel;
use App\Models\System\User;

class Login extends BaseModel
{
    protected $table = 'log__logins';

    const APP_KEY = 'app';
    protected $fillable = [
        'id',
        'user_id',
        'app_id',
        'ip',
        'token',
        'deleted_at',
        'updated_at',
        'created_at'
    ];


    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    /**
     * 状态文本
     * @param $value
     * @return mixed
     */
    public function getAppTextAttribute($value)
    {
        return $this->getCode(self::APP_KEY, $value);
    }

}